如何在包更新之間保留data_files?
我使用的data_files
參數setuptools.setup()
將配置文件安裝到/etc
和用戶主目錄。但是,使用pip install <package-name>
更新軟件包會在安裝新版本之前卸載舊版本和所有配置文件。如何在包更新之間保留data_files?
如何在更新期間保留配置文件,如果它們已被更改?
我非常懷疑雞蛋或輪子「安裝者」可以做到這一點。它們是相當簡單的原始分佈格式(卸載以前的版本,安裝新的覆蓋文件),但僅此而已。
要做你想要的東西,你可能需要一個真正的安裝程序(rpm或deb) - 它們可以保存更改的配置文件。但它們很複雜,很難創建格式。
如果你堅持使用簡單的車輪,我可以建議停止分發配置文件。而是分發配置文件的模板,並教導用戶從這些模板創建配置文件。然後新版本只會覆蓋模板,而不是真正的配置文件。
點擊ctrl-c在安裝spacy時,現在在嘗試再次安裝時出現錯誤
我正在嘗試安裝spacy。我在CentOS Linux上點擊ctrl-c在安裝spacy時,現在在嘗試再次安裝時出現錯誤
!pip install -U spacy
在jupyter筆記本和一切工作正常。在安裝過程中,我意識到我打算包含--user命令,因爲我只打算爲我的用戶安裝,所以我點擊了ctrl-c。此時安裝不完整。
嘗試用pip再次安裝軟件包現在給我一個錯誤,無論我是否包含--user標誌。我認爲下面的錯誤與不完整的構建有關。有誰知道如何解決這一問題?
Collecting spacy
Exception:
Traceback (most recent call last):
File "/opt/anaconda2/lib/python2.7/site-packages/pip/basecommand.py", line
215, in main
status = self.run(options, args)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/commands/install.py",
line 335, in run
wb.build(autobuilding=True)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/wheel.py", line 749, in
build
self.requirement_set.prepare_files(self.finder)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/req/req_set.py", line
380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/opt/anaconda2/lib/python2.7/site-packages/pip/req/req_set.py", line
620, in _prepare_file
session=self.session, hashes=hashes)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/download.py", line 809,
in unpack_url
unpack_file_url(link, location, download_dir, hashes=hashes)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/download.py", line 715,
in unpack_file_url
unpack_file(from_path, location, content_type, link)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/utils/__init__.py",
line 599, in unpack_file
flatten=not filename.endswith('.whl')
File "/opt/anaconda2/lib/python2.7/site-packages/pip/utils/__init__.py",
line 484, in unzip_file
zip = zipfile.ZipFile(zipfp, allowZip64=True)
File "/opt/anaconda2/lib/python2.7/zipfile.py", line 770, in __init__
self._RealGetContents()
File "/opt/anaconda2/lib/python2.7/zipfile.py", line 811, in _
RealGetContents
raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file`
在pip上安裝編譯C庫
我做了一個需要執行C函數的Python應用程序。爲此,我使用gcc將C函數編譯到共享庫中,並使用ctypes在我的Python腳本中調用該庫。在pip上安裝編譯C庫
我試圖在pip包中打包我的應用程序,但發現無法在pip安裝時創建共享庫。
我嘗試以下(setup.py):
from setuptools import setup
from setuptools.command.install import install
import subprocess
class compileLibrary(install):
def run(self):
install.run(self)
command = "cd packageName"
command += " && git clone https://mygit.com/myAwesomeCLibrary.git"
command += " && gcc -my -many -options"
process = subprocess.Popen(command, shell=True)
process.wait()
setup(
name='packageName',
version='0.1',
packages=['packageName'],
install_requires=[
...
],
cmdclass={'install': compileLibrary},
)
做python setup.py install
的時候,但從PIP安裝時,此工作,而安裝過程是成功的,共享庫是不在包文件夾(pythonx.x/site-packages/packageName
)中。
我嘗試使用distutils的結果相同。
基於問題Run Makefile on pip install我也試過以下setup.py:
??這裏是我的包
packageName/
├── packageName/
│ ├── __init__.py
│ ├── myFunctions.c
├── MANIFEST.in
├── README.md
├── setup.py
注意的體系結構:與PIP安裝包後,我只安裝文件夾中有__init__.py
和__pycache__
(pythonx.x/site-packages/packageName
)。
如何在pip安裝期間創建共享庫,以便它可以被我的包使用?
經過數小時的研究,我找到了解決方案。存在的主要問題是:
- 使用
Extension
從setuptools
編譯庫 - 使用自定義安裝功能
git clone
和調用構造函數末所以git clone
編譯之前發生。
這裏是工作setup.py
:
from setuptools import setup, Extension
from setuptools.command.install import install
import subprocess
import os
class CustomInstall(install):
def run(self):
command = "git clone https://mygit.com/myAwesomeCLibrary.git"
process = subprocess.Popen(command, shell=True, cwd="packageName")
process.wait()
install.run(self)
module = Extension('packageName.library',
sources = ['packageName/library.c'],
include_dirs = ['packageName/include'],
extra_compile_args=['-fPIC'])
setup(
name='packageName',
version='0.1',
packages=['packageName'],
install_requires=[
...
],
cmdclass={'install': CustomInstall},
include_package_data=True,
ext_modules=[module],
)
您可以在MANIFEST.in添加共享庫。 是這樣的: include *.so *.dylib
謝謝,但我想在pip安裝期間編譯庫。 –
所以你想使用CustomInstall而不是CustomBuild。 –
發送二進制圖像通過管道在python到C服務器
所以我試圖發送一個文件(在這種情況下一個.jpg圖像)二進制從客戶端在python 3到C服務器通過管道和由於某種原因它顯示錯誤,水管壞了,這裏是代碼: 蟒蛇:發送二進制圖像通過管道在python到C服務器
import os,sys,errno,pipes,signal,time
def Tuberia():
fifo = "/tmp/fifoNombre"
print ("conecting to a pipe...",fifo)
file = open("/home/luisro/Pictures/64.jpg","r+b")
f = open(fifo,'wb')
for line in file:
print(line)
f.write(line)
f.close()
file.close()
以及C服務器:
void reciveFile(){
int fn;
char * fifoNombre = "/tmp/fifoNombre";
// //opens the pipe for reading
mkfifo(fifoNombre, 0666);
unsigned char datos[MAX_BUF];
fn = open(fifoNombre, O_RDONLY);
read(fn, datos, MAX_BUF);
saving(datos,"/home/luisro/Desktop/algo.jpg");
unlink(fifoNombre);
}
void saving(unsigned char *data, char* dirDest){
FILE *flujoArchivo = fopen(dirDest, "wb");
if(flujoArchivo == NULL){
printf("Error saving.
");
exit(-1);
}
int writed_size = fwrite(data, sizeof(unsigned char), MAX_BUF, flujoArchivo);
fclose(flujoArchivo);
}
所以這些都是功能我不知道,如果是Python客戶端或問題的C服務器,提前致謝
,所以我解決這個問題而不進行循環是這樣的:
def Tuberia():
print("sending file")
fifo = "/tmp/fifoNombre"
print ("connecting to pipe...",fifo)
try:
f = open(fifo,'wb')
with open("/home/luisro/Pictures/64.jpg","r+b") as file:
line = file.read()
f.write(line)
print("sending succesfully...")
except:
print("problem connecting to pipe
")
Tuberia()
print("closing conexions....")
time.sleep(2)
file.close()
f.close()
的另一個問題是該文件的權重996.9 KB時,它的發送權重8.3 MB至極是MAX_BUF的在C服務器規模做任何人都知道如何爲任何文件發送正確的大小?
這裏是C服務器:
void reciveFile(){
int fn;
char * fifoNombre = "/tmp/fifoNombre";
// //opens the pipe for reading
mkfifo(fifoNombre, 0666);
unsigned char datos[MAX_BUF];
fn = open(fifoNombre, O_RDONLY);
read(fn, datos, MAX_BUF);
saving(datos,"/home/luisro/Desktop/algo.jpg");
unlink(fifoNombre);
}
void saving(unsigned char *data, char* dirDest){
FILE *flujoArchivo = fopen(dirDest, "wb");
if(flujoArchivo == NULL){
printf("Error saving.
");
exit(-1);
}
int writed_size = fwrite(data, sizeof(unsigned char), MAX_BUF, flujoArchivo);
fclose(flujoArchivo);
}
使用pip安裝pymssql失敗並鏈接到使用Mac上的fink安裝的FreeTDS
我在iMac上運行MacOS 10.11.6(El Capitan)。我建立了一個Python 3.4.7虛擬環境,並且我已經安裝了各種軟件包,包括numpy,pandas,scipy等。但是,我很難安裝pymssql。我知道我需要首先安裝FreeTDS,並且我已經使用fink(它安裝了freetds版本0.91-5)來完成此操作。然而,當我啓動一個虛擬的環境和運行:使用pip安裝pymssql失敗並鏈接到使用Mac上的fink安裝的FreeTDS
pip install pymssql
我收到以下錯誤消息(道歉它的大小):使用自制安裝freetds的
Collecting pymssql
Using cached pymssql-2.1.3.tar.gz
Complete output from command python setup.py egg_info:
Download error on https://pypi.python.org/simple/setuptools_git/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) -- Some packages may not be found!
Download error on https://pypi.python.org/simple/setuptools-git/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) -- Some packages may not be found!
Couldn't find index page for 'setuptools_git' (maybe misspelled?)
Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) -- Some packages may not be found!
No local packages or working download links found for setuptools_git
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/75/qtnqhywh8xj9760059b8dbd80000gq/T/pip-build-pyxahulz/pymssql/setup.py", line 477, in <module>
ext_modules = ext_modules(),
File "/Users/xyz/Documents/python_projects/general_python34_projects/env34/lib/python3.4/site-packages/setuptools/__init__.py", line 128, in setup
_install_setup_requires(attrs)
File "/Users/xyz/Documents/python_projects/general_python34_projects/env34/lib/python3.4/site-packages/setuptools/__init__.py", line 123, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/Users/xyz/Documents/python_projects/general_python34_projects/env34/lib/python3.4/site-packages/setuptools/dist.py", line 453, in fetch_build_eggs
replace_conflicting=True,
File "/Users/xyz/Documents/python_projects/general_python34_projects/env34/lib/python3.4/site-packages/pkg_resources/__init__.py", line 866, in resolve
replace_conflicting=replace_conflicting
File "/Users/xyz/Documents/python_projects/general_python34_projects/env34/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1146, in best_match
return self.obtain(req, installer)
File "/Users/xyz/Documents/python_projects/general_python34_projects/env34/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1158, in obtain
return installer(requirement)
File "/Users/xyz/Documents/python_projects/general_python34_projects/env34/lib/python3.4/site-packages/setuptools/dist.py", line 520, in fetch_build_egg
return cmd.easy_install(req)
File "/Users/xyz/Documents/python_projects/general_python34_projects/env34/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 666, in easy_install
raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('setuptools_git')
setup.py: platform.system() => 'Darwin'
setup.py: platform.architecture() => ('64bit', '')
setup.py: platform.libc_ver() => ('', '')
setup.py: Detected Darwin/Mac OS X.
You can install FreeTDS with Homebrew or MacPorts, or by downloading
and compiling it yourself.
Homebrew (http://brew.sh/)
--------------------------
brew install freetds
MacPorts (http://www.macports.org/)
-----------------------------------
sudo port install freetds
setup.py: Not using bundled FreeTDS
setup.py: include_dirs = ['/sw/include']
setup.py: library_dirs = ['/usr/local/lib', '/sw/lib', '/opt/local/lib']
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/75/qtnqhywh8xj9760059b8dbd80000gq/T/pip-build-pyxahulz/pymssql/
網上說明介紹但我一直使用fink,不想與兩個系統安裝的代碼產生衝突。
我已經更新了fink和pip,並且安裝了最新的setuptools。
我試着運行:
pip install --global-option=build_ext --global-option="-L/sw/lib" --global-option="-I/sw/include" pymssql
...但沒有運氣。
我也嘗試安裝pymssql的早期版本:
pip install pymssql==2.1.1
同樣,沒有喜悅。
或者是錯誤輸出密鑰開始處的'證書驗證失敗'註釋?
我確定我以前在其他機器上安裝過MSSQL,我不記得有任何問題。我也不記得我做了什麼不同(如果有的話)。
任何人都可以幫助我解決這個問題,請。
最初的虛擬環境是使用Python 3.4.7創建的,它使用fink安裝。
我最終刪除了這個虛擬環境,並使用從python.org下載的python 3.4.4重新創建了一個新的虛擬環境。這些軟件包被重新安裝(使用pip freeze)並安裝了pymssql,完全沒有問題。
所以,雖然我仍然不知道是什麼原因導致了原來的問題,至少我現在有一個工作環境。
在windows10上安裝tensorflow -python 3.6.1(anaconda)
我試圖將tensorflow安裝到我的機器上,但運行不正常。在windows10上安裝tensorflow -python 3.6.1(anaconda)
我參考tensorflow主頁,並決定安裝它與anaconda,目前我正在運行我的python。
所以我做..
>conda create -n tensorflow python=3.5 #One of the posts on Stackoverflow
#told the other to put 'python=3.5' even when
#installing on python3.6.x.. So I did as what's said
>activate tensorflow
(tensorflow)>pip install --ignore-installed --upgrade tensorflow
但是當我運行上面的最後一行,我得到:
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions:)
No matching distribution found for tensorflow
我應該怎麼做來解決我的問題?
順便說一句,我的點子的版本是9.0.1 /蟒蛇30年3月4日/ Python的3.6.1
我覺得tensorflow尚不可用的Python 3.6。
如果您使用anaconda,您可以嘗試使用python 3.5設置虛擬環境。
你可以嘗試在此窗口中的測試版本,
PIP安裝-i https://testpypi.python.org/pypi tensorflow
或者你可以嘗試從車輪文件中像這樣安裝tensorflow(雖然這沒」我成功了):
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl
TensorFlow確實已將python 3.6二進制文件上傳到pypi。 你只需要在管理員終端中運行pip install tensorflow
就是這樣。 在windows上,使用anaconda的Windows常見問題是,您幾乎總是需要具有管理員權限的終端來安裝任何東西。所以這可能會導致你的問題。
URL到最新的Windows蟒蛇3.6 PIP封裝: https://pypi.python.org/packages/76/7b/2048b4ecd88395ac16ab938e8675ffeda2acb60bc34f5ef63500eafafaf5/tensorflow-1.4.0-cp36-cp36m-win_amd64.whl#md5=7bdc1e94f1cb772ae5851018dc23a62e
TensorFlow的Windows官方安裝文檔: https://www.tensorflow.org/install/install_windows
嗯..我用管理員權限進行安裝。但我仍然得到相同的信息: '收集張量流 找不到符合要求張量流的版本(從版本:) 張量流找不到匹配的分佈' –
如果沒有'conda create ....'命令正在運行,然後只是'pip安裝tensorflow'? – gunan
Python:升級我自己的包
我通過以下操作創建並安裝了一個python包:在init .py文件中編寫一堆函數,然後運行'python setup.py install dist'創建一個tar.gz ,這是通過點安裝。 一切正常,我可以導入包和函數。 我決定在init文件中添加一個新函數,並重新編寫上述的所有過程以重新安裝(或更新)我的軟件包。 添加的新功能在導入軟件包時似乎不可用,即使在更新後也是如此。 關於如何更新我的包的任何想法?Python:升級我自己的包
如果您正在積極開發包,請考慮使用'python setup.py develop'來代替,以便更改立即反映到環境中。 – metatoaster
@metatoaster說了些什麼,或者做'pip安裝。 -e'。 –
謝謝metatoaster,正如你所說的變化並沒有立即反映在環境中。您的命令會立即進行更改。 – monty47
正如@metatoaster建議的那樣,python setup.py develop
反映環境中立即發生的變化,並使新功能可用。 我還沒有試過@保羅H的建議是pip install . -e
。 謝謝你的評論,問題解決了。
ForEach-Object是否對管道中的單個對象或對象集合進行操作?
我很難理解PowerShell管道是如何工作的,我意識到很多問題都是由於ForEach-Object
造成的。在我用過的其他語言中,foreach對集合進行操作,並依次遍歷集合中的每個元素。我假設ForEach-Object
在PowerShell管道中使用時,會執行相同的操作。但是,我讀到的關於管道的所有信息都表明,集合中的每個元素分別通過管道傳遞,並且下游的cmdlet被重複調用,分別在每個元素上運行,而不是整個集合。ForEach-Object是否對管道中的單個對象或對象集合進行操作?
因此,ForEach-Object
是對集合中的單個元素進行操作,而不是對集合進行整體操作?用不同的方式來看,管道操作員是否將整個集合傳遞給ForEach-Object
,然後對其進行迭代,或者管道對象是否迭代集合並將每個元素單獨傳遞給ForEach-Object
?
的ForEach-Object
cmdlet的 - 不像foreach
聲明 - 本身執行沒有枚舉。
相反,它對通過管道傳遞的每個項目進行操作(在接收第一個項目之前以及在接收到最後一個項目之後,還可以選擇執行代碼)。
因此,可以說是很差命名,因爲它是管道提供枚舉(默認),並且ForEach-Object
只是調用對於接收到的每個項的腳本塊。
下面的例子說明這一點:
# Let the pipeline enumerate the elements of an array:
> 1, 2 | ForEach-Object { "item: [$_]; count: $($_.Count)" }
item: [1]; count: 1
item: [2]; count: 1
# Send the array *as a whole* through the pipeline (PSv4+)
> Write-Output -NoEnumerate 1, 2 | ForEach-Object { "item: [$_]; count: $($_.Count)" }
item: [1 2]; count: 2
注意腳本/功能/ cmdlet的可選擇他們寫入到輸出流(管道)的集合是否應該列舉或發送作爲一個整體(作爲一個單一的對象)。
在PowerShell代碼(腳本或功能,無論是先進的(小命令狀)與否,枚舉是默認的,但你可以Write-Output -NoEnumerate
退出;在-NoEnumerate
開關是PSv4介紹,在此之前,你不得不使用$PSCmdlet.WriteObject()
,這是僅適用於先進腳本/功能。
還要注意,在表達嵌入的命令通過在(...)
力枚舉包圍它:
# Send array as a whole.
> Write-Output -NoEnumerate 1, 2 | Measure-Object
Count: 1
...
# Converting the Write-Output -NoEnumerate command to an expression
# by enclosing it in in (...) forces enumeration
> (Write-Output -NoEnumerate 1, 2) | Measure-Object
Count: 2
...
ForEach-Object
迭代集合中的每個項目。當它完成對當前項目執行的腳本塊時,它會沿管道發送到下一個可以立即開始處理的命令(而ForEach-Object
正在處理下一個項目,如果有的話)。
您可以在下面的例子中看到這些內容起作用:
Get-Process | ForEach-Object { Start-Sleep 1; $_ } | Format-Table
的Get-Process
cmdlet獲取進程的列表,並立即發送到每一個ForEach-Object
在同一時間。 ForEach-Object
正在等待1秒,然後輸出當前的管線元素$_
。這被Format-Table
收到,它將它作爲表格輸出。您可以看到,它不會等到所有進程都處理完才輸出到屏幕。
答案是......兩者都有。
支持流水線操作的PowerShell函數(高級函數)流程每個項目單獨通過流水線。它還可以定義一個begin
和end
塊,它將在流水線階段只執行一次。換句話說,基本的結構是這樣的:
function Do-Stuff {
begin {
write-output "This will be done once, at the beginning"
}
process {
Write-output "This will be done for each item"
}
end {
Write-output "This will be done once, at the end"
}
}
的1..3 | foreach-Object {Do-Stuff $_}
的輸出將是:
This will be done once, at the beginning
This will be done for each item
This will be done for each item
This will be done for each item
This will be done once, at the end
由於Do-Stuff
被寫入到輸出流,如果這之後存在額外的流水線級Foreach-Object
,每個對象輸出將依次傳遞到下一個階段。如果沒有其他階段或其他任何東西來捕獲輸出,輸出流將被寫入控制檯。
例如:
$verbosepreference = "continue";
[int]1..3|foreach-object {write-output $_; write-verbose ($_*-1)}|foreach-object {$_*$_;write-verbose $_}
給出以下輸出:
1
VERBOSE: 1
VERBOSE: -1
4
VERBOSE: 2
VERBOSE: -2
9
VERBOSE: 3
VERBOSE: -3
-X
輸出到最後的冗長流(每個項目),因爲輸出被傳遞到下一階段在之前的管道和foreach-object
腳本塊中的下一個語句被執行。
快速撥出:'[INT] 1..3'相同'([INT] 1).. 3',這是因爲剛'1..3'相同,假設範圍運算符表達式的結果是_always_ a(帶有[[int]'元素的'[System.Object []]')數組。不管怎麼說,像'1'和'3'這樣的數字文字都是'[int]'-type,但即使它們不是,PowerShell也會簡單地強制它們;例如「1」,「3」將產生相同的結果。 – mklement0
PyPI /簡單不提供最新版本的包
我上傳a library到PyPI昨晚 - 它目前在版本0.0.3。嘗試使用pip版本0.0.1安裝庫時。已安裝。運行pip install pyroblox --upgrade
,點決定0.0.1是最新版本。與卸載然後重新安裝相同。我想這可能是一個緩存的問題,但這樣做一個詳細的安裝時,我看到PIP被選中此網址最新的版本:PyPI /簡單不提供最新版本的包
https://pypi.python.org/simple/pyroblox/
的/簡單的頁面只包含版本0.0.1 - 不是0.0.2或0.0.3。自從我上傳0.0.2版本以來,已經過了15個小時,所以我認爲這不是一個PyPI的問題,只是運行緩慢的cron作業來更新/簡單頁面。
當上傳包到PyPI以使它們在/簡單頁面上更新時,還有什麼額外的東西需要處理嗎?現在我正在運行python setup.py sdist
,然後運行twine upload dist/pyRoblox-x-x-x.tar.gz
。這似乎更新普通頁面很好,但/簡單卡住0.0.1。我可以直接從源代碼安裝包,但我希望通過點安裝來正確運行,以便分發包。
Maven使用jenkins for scala編譯spark程序:「沒有主要的神器安裝,而是安裝附加的工件
我有一個項目有多個scala spark程序,而我通過eclipse運行mvn install我能夠得到正確的jar生成的使用spark-submit命令運行Maven使用jenkins for scala編譯spark程序:「沒有主要的神器安裝,而是安裝附加的工件
將代碼推送到GIT之後,我們試圖使用jenkins來構建它,因爲我們想要使用無法自動將jar文件推送到我們的hadoop集羣 我們有jenkinsfile與建立目標爲「編譯軟件包安裝-X」
日誌顯示 -
[DEBUG](f)artifact = com.esi.rxhome:PROJECT1:jar:0.0.1-SNAPSHOT
[DEBUG](f) attachedArtifacts = [com.esi.rxhome:PROJECT1:jar:jar- with-dependencies:0.0.1-SNAPSHOT, com.esi.rxhome:PROJECT1:jar:jar-with-dependencies:0.0.1-SNAPSHOT]
[DEBUG] (f) createChecksum = false
[DEBUG] (f) localRepository = id: local
url: file:///home/jenkins/.m2/repository/
layout: default
snapshots: [enabled => true, update => always]
releases: [enabled => true, update => always]
[DEBUG] (f) packaging = jar
[DEBUG] (f) pomFile = /opt/jenkins-data/workspace/ng_datahub-pipeline_develop-JYTJLDEXV65VZWDCZAXG5Y7SHBG2534GFEF3OF2WC4543G6ANZYA/pom.xml
[DEBUG] (s) skip = false
[DEBUG] (f) updateReleaseInfo = false
[DEBUG] -- end configuration --
[INFO] **No primary artifact to install, installing attached artifacts instead**
我看到了類似的帖子錯誤 -
Maven: No primary artifact to install, installing attached artifacts instead
但這裏的答案說 - 自動刪除乾淨,我不知道如何停止,儘管詹金斯正在建設的jar文件。
下面是pom.xml-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.esi.rxhome</groupId>
<artifactId>PROJECT1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>RxHomePreprocessing</description>
<inceptionYear>2015</inceptionYear>
<licenses>
<license>
<name>My License</name>
<url>http://....</url>
<distribution>repo</distribution>
</license>
</licenses>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.10.6</scala.version>
<scala.compat.version>2.10</scala.compat.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.specs2</groupId>
<artifactId>specs2-core_${scala.compat.version}</artifactId>
<version>2.4.16</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.compat.version}</artifactId>
<version>2.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>1.2.1000.2.6.0.3-8</version>
</dependency>
<!-- <dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.10</artifactId>
<version>2.1.0</version>
</dependency> -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.10</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_2.10</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>com.databricks</groupId>
<artifactId>spark-csv_2.10</artifactId>
<version>1.5.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-make:transitive</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<useFile>false</useFile>
<disableXmlReport>true</disableXmlReport>
<!-- If you have classpath issue like NoDefClassError,... -->
<!-- useManifestOnlyJar>false</useManifestOnlyJar -->
<includes>
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.esi.spark.storedprocedure.Test_jdbc_nospark</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
我試圖指定
1 - 「罐」 中的pom.xml包裝。
2 - 改變Maven目標來 -
「安裝」
「全新安裝」
「編譯包安裝」
但上面的嘗試並沒有幫助擺脫消息和創建的jar是沒用的。
當我嘗試執行火花提交命令 -
spark-submit --driver-java-options -Djava.io.tmpdir=/home/EH2524/tmp --conf spark.local.dir=/home/EH2524/tmp --driver-memory 2G --executor-memory 2G --total-executor-cores 1 --num-executors 10 --executor-cores 10 --class com.esi.spark.storedprocedure.Test_jdbc_nospark --master yarn /home/EH2524/PROJECT1-0.0.1-20171124.213717-1-jar-with-dependencies.jar
Multiple versions of Spark are installed but SPARK_MAJOR_VERSION is not set
Spark1 will be picked by default
java.lang.ClassNotFoundException: com.esi.spark.storedprocedure.Test_jdbc_nospark
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.spark.util.Utils$.classForName(Utils.scala:175)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:703)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
這裏,Test_jdbc_nospark是Scala的對象。
此消息是因爲maven-jar-plugin具有真實性。一旦我刪除此,構建沒有給消息「沒有主神器安裝,安裝附加的文物,而不是」
空罐子在pom.xml中得到創建,因爲不正確的路徑的
Intitally-
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
由於jenkins是通過git中的代碼構建的,而pom在項目文件夾中。
<build>
<sourceDirectory>folder_name_in_git/src/main/scala</sourceDirectory>
我不確定,但您的maven-jar-plugin
配置看起來很可疑。通常,執行將指定階段,如
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
(來自this example)。也許省略這會導致你的默認jar不能被構建?當然,錯誤消息聽起來像你的默認jar沒有被構建,但你實際上並沒有這麼說。
此消息是因爲具有
進一步挖掘,我看到詹金斯正在打印消息,沒有編譯的源代碼導致創建一個空罐子。 ? ('[INFO] --- maven-compiler-plugin:3.1:compile(default-compile) @ PROJECT1 --- [INFO] No source to compile'?) 試圖明白爲什麼它無法獲得來源編譯。 @Joe – Jim
在Eclipse前端(我使用IntelliJ)無法提供幫助,但聽起來您的Eclipse項目似乎沒有使用Maven使用的默認配置。 –
當您執行作業或ps aux |時,您是否看到任何相關進程或作業? grep pip'? – JacobIRR
您也可以嘗試通過設置'--no-cache-dir'標誌來禁用pip緩存。 –
車輪文件可能已損壞或不完整。試試'pip install --upgrade --force-reinstall spacy' –